using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Windows;

public class VirturalInput : MonoBehaviour
{
    private float currentValue = -1f;
    private float duration = 1f;
    private float elapsedTime = 0f;
    private bool increasing = true;
    public WheelLegInputer inputer;
    public float random_val = 0.05f;
    private void Start()
    {
        inputer.input_flag = false;
    }
    void Update()
    {
        elapsedTime += Time.deltaTime+ random_val * Random.value;

        if (increasing)
        {
            currentValue = Mathf.Lerp(-1f, 1f, elapsedTime / duration);
            if (elapsedTime >= duration)
            {
                currentValue = 1f;
                elapsedTime = 0f;
                increasing = false;
            }
        }
        else
        {
            currentValue = Mathf.Lerp(1f, -1f, elapsedTime / duration);
            if (elapsedTime >= duration)
            {
                currentValue = -1f;
                elapsedTime = 0f;
                increasing = true;
            }
        }
        inputer.axis_values[1] = currentValue;
        //Debug.Log(currentValue);
    }
}
